<?
include_once('./xml.php');

class Properties {
    protected $xml_file;
    protected $properties;

    public function __construct($xml_file) {
        $this->properties = $this->readPropertiesFromXML($xml_file);
        #print_r($this->properties);
        $this->xml_file = $xml_file;
    }

    public function readPropertiesFromXML($xml_file) {
        $data = file_get_contents($xml_file);
        return XML_unserialize($data);
    }

    public function getProperties() {
        return $this->properties;
    }

    public function writePropertiesXML() {
        print_r($this->properties);
        $xml = XML_serialize($this->properties);
        file_put_contents($this->xml_file, $xml);
    }

    public function updateProperties($properties) {
        $this->properties = $properties;
        $this->writePropertiesXML();
    }

}
/* Usage example of this class below
$properties_reader = new Properties('./properties.xml');
$properties = $properties_reader->getProperties();
print_r($properties);
$properties['theme-config']['theme-basics']['logo'] = 'updated';
$properties_reader->updateProperties($properties);
*/


?>
